var wechat = require('wy-WeChat');
cc.Class({
    extends: wechat,

    properties: {
    },
    init(){
        this._super();
        this.os = 'tt'
        this.isTouTiao = true
        this.isWechat = false;
    },

    login(cb){
        tt.login({
            success: (res) => {
                var code = res.code;
                console.log('头条登陆成功')
                var systemInfo = tt.getSystemInfoSync();
                var width = 194;
                var height = 55;
                var left = systemInfo.screenWidth / 2 - width / 2;
                var top = 0.84 * systemInfo.screenHeight - height / 2;
                wx.getUserInfo({
                    withCredentials: true,
                    lang: 'cn',
                    success: (res) => {
                        console.log('getUserInfo:', res)
                        res.code = code
                        Object
                        cb(res);
                    },
                    fail: () => {
                        wx.openSetting({
                            authSetting: ['scope.userInfo'],
                            success: (res) => {
                                this.login(cb);
                            },
                            fail: (err) => {
                                this.login(cb);
                            }
                        })
                    }
                })
            },
            fail: function (err) {
                console.log('头条登陆失败:', err);
            }
        });
    }
});
